# -*- coding: utf-8 -*-
# File : service.py
# Author: taoyahui
# Date : 2021/5/20

import json
import requests
import configparser

cf = configparser.ConfigParser()
cf.read("config.ini")
host = cf.get("FISCO-BCOS", "host")
port = cf.get("FISCO-BCOS","port")

#通用请求fisco bcos接口信息内容
def common_request(d):
    url = f"http://{host}:{port}"
    # d = {"jsonrpc": "2.0", "method": "getClientVersion", "params": [], "id": 1}
    headers = {
        'content-type': 'application/json'
    }
    res = requests.request(method="POST", url=url, data=json.dumps(d), headers=headers)
    return json.loads(res.content)
